package com.spancer.contentcenter.test.listener;

import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.core.annotation.Order;

/**
 * author by: mars
 * Date: 2020/10/13 13:14
 * Description:自定义监听器-方式4：
 * > implements SmartApplicationListener
 *
 */
@Order(4)
public class FourListener implements SmartApplicationListener {

    @Override
    public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
        // 对哪些事件感兴趣
        return ApplicationStartedEvent.class.isAssignableFrom(eventType)
                ||  ApplicationPreparedEvent.class.isAssignableFrom(eventType);
    }

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        System.out.println("four-mss listener...");
    }
}
